# -*- encoding: utf-8 -*-
"""
@File : calculator.py
@Time : 2021/6/14 13:44
@Author : Linleil
"""


class Calculator:
    @staticmethod
    def bmi_calculate(height=False, weight=False):
        if height and weight:
            try:
                height = float(height)
                weight = float(weight)
                bmi = weight / (height ** 2)
                status = True
                return status, bmi
            except:
                status = False
                message = 'error input'
                return status, message
        else:
            status = False
            message = 'without data'
            return status, message

    @staticmethod
    def judge_bmi(bmi=False):
        if bmi:
            try:
                bmi = float(bmi)
                if bmi < 18.5:
                    grade = '偏瘦'
                elif bmi < 24:
                    grade = '正常'
                elif bmi < 28:
                    grade = '超重'
                else:
                    grade = '肥胖'

                status = True
                return status, grade

            except:
                status = False
                message = 'valid input'

        else:
            status = False
            message = 'without input'

        return status, message
